<html>
	<head>
	<link rel="icon" type="image/png" href="images/favicon.png" />
	<link href="style.css" rel="stylesheet" type="text/css" />
	<title>Express Wallet</title>
	</head>
</html>
<?
if (isset($_POST["id"])) 
{
include("cgi/mysqli_connect_read.php");

$id = mysqli_real_escape_string($con,$_POST["id"]);
$address = $_POST["address"];
$amount = $_POST["amount"]*100000000;

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM wallets WHERE id = '$id'");

$row = mysqli_fetch_array($result);

$private_key = $row['private_key'];

if (isset($_POST["address"]))
	{
	$json_url = "https://blockchain.info/merchant/$private_key/payment?to=$address&amount=$amount";

	$json_data = file_get_contents($json_url);

	$json_feed = json_decode($json_data);

	$message = $json_feed->message;
	$txid = $json_feed->tx_hash;
	$error = $json_feed->error;
	
	echo $message;
	echo $error;	
	echo '<meta http-equiv="refresh" content="5; url=/">';
	}
else
	{
	echo "User not found!";
	echo '<meta http-equiv="refresh" content="5; url=/">';
	}
}
else
	{
	echo "You IP has been logged for suspicios activity.";
	echo '<meta http-equiv="refresh" content="5; url=http://www.fbi.gov">';
	}
?>